
using AutoMapper;
using Domain.Models;
using Extensions.Attributes;
using IRepository;
using IServices;
using Services.Base;
using System.Collections.Generic;
using System.Linq;

namespace Services
{
    public class DictsService : BaseService<Dicts>, IDictsService
    {
        protected readonly IDictsRepository dictsRepository;

        public DictsService(IDictsRepository dictsRepository, IMapper mapper) : base(mapper)
        {
            this.dictsRepository = dictsRepository;
            base.baseRepository = dictsRepository;
        }
        [Caching(AbsoluteExpirationReleativeToNow = 1200)]
        public IEnumerable<Dicts> GetDicts()
        {
            return this.dictsRepository.Query();
        }

        public Dicts GetDicts(string name)
        {
            var result = new Dicts();
            var value = this.GetDicts().Where(x => x.Name == name).FirstOrDefault();
            if (value != null)
            {
                result = value;
            }
            return result;
        }
    }

}